<template>
	<view class="container">
		<u-navbar title="生活护航员" :title-bold='true' background="#6EC9E1" :is-fixed="true" z-index='999'
			:border-bottom="false" title-color="#FFF" back-icon-color="#FFF" :customBack='true' @leftEvent='back'>
		</u-navbar>

		<h1>生活咨询：有“3次回访”，就够了！</h1>

		<view class="card">
			<image class="certificate" :src="userInfo.certificate" mode="widthFix"></image>
			<view>
				<view class="c-u">
					<view class="name">{{userInfo.username}}</view>
					<view>{{userInfo.speciality || ''}}</view>
				</view>
				<view class="c-u">
					<image src="@/static/img/mine/yiyuan.png" mode=""></image>
					<view class="institution">{{userInfo.institution ||'--' }}</view>
				</view>
			</view>
		</view>

		<view class="card">
			<view class="experience">
				<view class="title">工作历程</view>
				<view class="item" v-for="(item,index) in userInfo.work" :key="index">
					<view class="line-dot">
						<view class="dot"></view>
						<u-line v-if="index<2" direction=' col' length='100%' color="#D8D8D8"></u-line>
					</view>
					<text class="time">{{item.start_time +'~'+ item.end_time }}</text>
					<view class="work">
						{{item.company||''}}
					</view>
				</view>
			</view>
		</view>

		<view class="event">
			<view class="left" @click="HandlerEvent">信得过+1</view>
			<view class="right" @click="logout">登录</view>
		</view>

		<button open-type="share"
			style="background-color: #6EC9E1;color: #FFF;border: 1rpx solid #FFF;height: 50px;box-sizing: border-box;">
			<image style="width: 18px;margin-right: 20rpx;" src="../../static/icon/share.png" mode="widthFix"></image>
			让好友点评
		</button>

		<view class="remake">
			<p>己所欲，应广施于人!</p>
			<p>知识不是力量，知识传播出去，</p>
			<p>用于实践，用之于民，才是力量。</p>
			<p>生活中的便利，分享给好友，这是我的责任!</p>
			<p style="margin-top: 30rpx;">赶紧去和生活护航员面谈，保持在线联系吧。</p>
		</view>
	</view>
</template>

<script>
	import {
		getDoctorInfo,
		chat,
		like,
		addCoupon
	} from '@/api/index.js'
	import {
		login,
	} from '@/api/login/login.js'
	export default {
		data() {
			return {
				userInfo: {
					work: []
				},
				doctor_id: '',
			}
		},
		onLoad(e) {
			if (e.id) {
				this.doctor_id = e.id
			}
			if (e.user) {
				this.ws.sid = `sid=${e.user}&type=2`
				this.ws.sid = encodeURIComponent(this.ws.sid)
			}
		},
		onShow() {
			this.init()

		},
		onShareAppMessage() {
			addCoupon().then(res => {
				console.log(res, '获得优惠券');
			})
			let pages = getCurrentPages(); //获取当前页面栈的信息
			let currentPage = pages[pages.length - 1]; //获取到当前页面栈中最后一个页面的索引
			// 乱加需求 靠
			let user = this.ws.getUserInfo()
			return {
				title: "生活咨询：有“3次回访”就够了！",
				imageUrl: "../../static/img/share.png", //封面图
				path: currentPage.route + `?id=${this.doctor_id}&user=${user.user_id}` //后面是路径上要传递的参数
			}
		},

		methods: {
			init() {
				let that = this
				getDoctorInfo({
					doctor_id: that.doctor_id
				}).then(res => {
					if (res.code == 1) {
						that.userInfo = res.data.info
					}
				})
			},
			logout() {
				this.ws.logout()
			},
			back() {
				const pages = getCurrentPages()
				if (pages.length > 1) {
					uni.navigateBack()
				} else {
					uni.switchTab({
						url: '/pages/message/message'
					})
				}

			},

			HandlerEvent() {
				let that = this
				like({
					doctor_id: that.doctor_id
				})
			},

			tochat(id) {
				let that = this
				chat({
					'user_id': id
				}).then(res => {
					if (res.code == 1) {
						that.ws.tochat(res.data.session_id)
					}
				})
			},
		}

	}
</script>

<style lang="less">
	.btu {
		display: flex;
		justify-content: space-around;
		align-items: center;
		margin-top: 20px;

		u-button {
			min-width: 30%;
		}
	}

	.remake {
		margin: 40rpx 0;
		opacity: 0.8;

	}

	.container {
		padding: 30rpx;
		background-color: #6EC9E1;
		min-height: 100vh;
		font-size: 15px;
		color: #FFF;

		h1 {
			margin: 10rpx 0;
			text-align: center;
		}

		.card {
			margin-top: 20rpx;
			background-color: #FFF;
			border-radius: 10rpx;
			padding: 30rpx;
			display: flex;
			align-items: center;
			color: #333333;

			.certificate {
				height: 86px;
				width: 74px;
				border-radius: 6px;
				margin-right: 20rpx;
				filter: blur(1px)
			}

			.auth {
				color: #6EC9E1;
				font-size: 14px;
			}

			.c-u {
				display: flex;
				align-items: center;
				font-size: 13px;

				image {
					height: 12px;
					width: 12px;
					margin-right: 12rpx;
				}

				.institution {
					font-size: 12px;
					opacity: 0.6;
				}

				.name {
					font-size: 24px;
					font-weight: 550;
					margin-right: 20rpx;
					margin-bottom: 20rpx;
				}

			}

			.experience {
				width: 100%;

				.title {
					font-size: 24px;
					margin-bottom: 20px;
					font-weight: 550;
				}

				.item {
					position: relative;
					display: flex;
					width: 100%;

					.line-dot {
						height: 57px;
						display: flex;
						flex-direction: column;
						align-items: center;
						margin-right: 20px;

						.dot {
							height: 15rpx;
							width: 15rpx;
							background-color: #D8D8D8;
							border-radius: 50%;
						}
					}

					.time {
						font-size: 13px;
						position: relative;
						top: -2rpx;
						color: #999999;
					}

					.work {
						position: absolute;
						width: 90%;
						top: calc(50% - 8px);
						left: 27px;
						font-size: 14px;

					}
				}
			}

			.expertise {
				p {
					color: #999999;
					line-height: 30px;
					margin-top: 10rpx;
				}
			}
		}


		.event {
			margin: 20px 0;
			display: flex;
			align-items: center;

			.left,
			.right {
				width: 50%;
				min-width: 160px;
				height: 57px;
				border-radius: 6px;
				display: inherit;
				align-items: center;
				justify-content: center;

				image {
					margin-right: 20rpx;
				}

				p {
					font-size: 12px;
				}
			}

			.right {
				background: #FDA43B;
				color: #FFF;
				margin-left: 15px;
			}

			.left {
				color: #6EC9E1;
				background: #FFF;
			}

			.left:active {
				transform: scale(0.9);
			}

			.right:active {
				transform: scale(0.9);
			}
		}


	}
</style>